<meta charset="UTF-8">
<style>
th{
	text-align:center
}
td{
	text-align:center
}
</style>
<div class="content-wrapper" style="min-height: 901px;">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1 style="text-align:center">
        	售价模板
      </h1>
    </section>

    <!-- Main content -->
    <section class="content">
      <div class="row">
        <div class="col-md-12">
          <div class="box">
          <div class="box-header">
          	<button class="btn btn-primary pull-left" data-toggle="modal" data-target="#newPrice"><i class="fa fa-plus"></i>&nbsp;&nbsp;新增模板</button>
          	&nbsp;
          
          	<button class="btn pull-right" ng-click="download('tb_price','售价模板')"><i class="fa fa-cloud-download"></i>&nbsp;&nbsp;导出</button>
          </div>
            <div class="box-body table-responsive no-padding">
              <table class="table table-hover">
                <tbody>
                <tr>
                  <th>序号</th>
                  <th>模块名称</th>
                  <th>适用餐卡类别</th>
                  <th>设置人</th>
                  <th>设置时间</th>
                  <th>操作</th>
                </tr>
                <!--<tr>
                	<td colspan="6" ng-if="dataLength == '0'">暂无数据</td>   
                </tr>-->
                <tr ng-repeat="p in items">
                  <td>{{$index+1}}</td>
                  <td>{{p.name}}</td>
                  <td>
                  	<span ng-repeat="n in p.card_type_names">{{n}}<span ng-if="!$last">&nbsp;</span></span>
                  </td>
                  <td>{{p.set_user}}</td>
                  <td>{{p.set_time}}</td>
                  <td>
                  	<!--<button class="btn btn-info" >修改</button>
                  	<button class="btn btn-danger" >删除</button>-->
                  	<a href="" class="btn btn-lg edit" style="padding:0px" title="修改" ng-click="showprice_edit(p.id)"><i class="fa fa-edit"></i></a>
                  	<a href="" class="btn btn-lg del" style="padding:0px" title="删除" ng-click="showPrice_del(p.id)"><i class="fa  fa-close"></i></a>
                  </td>
                </tr>
               </tbody>
			</table>
			<table class="table table-hover download" id="tb_price">
                <tbody>
                <tr>
                  <td>序号</td>
                  <td>模块名称</td>
                  <td>适用餐卡类别</td>
                  <td>设置人</td>
                  <td>设置时间</td>
                </tr>
                <tr ng-repeat="p in items">
                  <td>{{$index+1}}</td>
                  <td>{{p.name}}</td>
                  <td>
                  	<span ng-repeat="n in p.card_type_names">{{n}}&nbsp;</span>
                  </td>
                  <td>{{p.set_user}}</td>
                  <td>{{p.set_time}}</td>
                </tr>
               </tbody>
			</table>
            </div>
            <!-- /.box-body -->
             <div class="box-footer" style="margin-bottom:10px;">
	              	
	              		<div class="dataTables_info col-sm-2" id="example1_info" role="status" aria-live="polite">总条目数：{{totalNums}}</div>
	              	
	               
	                	
	                		<!--<label class="col-md-2" style="font-weight:normal;float:left;padding-right:15px;text-align: right;">每页显示数目 
	                			
	                		</label>-->
	                		<!--<div class="col-md-2">
	                			
	                		
	                		<select name="example1_length" aria-controls="example1" class="form-control input-sm" ng-change="change(initial)" ng-model="initial" > 
	                				<option value="10">10</option> 
	                				<option value="25">25</option>
	                				<option value="50">50</option>
	                				<option value="100">100</option>
	                		    </select>
	                		</div>-->
	                		<div class="col-md-6 col-md-offset-4">
	                			<ul class="pagination pull-right" style="margin: 0px;">
		                			<li class="paginate_button previous" id="example1_previous">
		                				<a  ng-click="Previous()">上一页</a>
		                			</li>
		                			<li   ng-repeat="page in pageList" ng-class="{active: isActivePage(page)}"><!-- class=" paginate_button active" -->
		                				<a  ng-click="selectPage(page)">{{page}}</a>
		                			</li>
		                			<li class="paginate_button next" id="example1_next">
		                				<a  ng-click="Next()">下一页</a>
		                			</li>
	                		</ul>
	                		</div>
	                		
	                	
	                
	              </div>
            </div>
          </div>
          <!-- /.box -->
        </div>
      </div>
    </section>
    <!-- /.content -->
  </div>
<!-- 删除售价模板  -->
  <div class="modal fade" id="delPrice" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" >
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" style="text-align:center">提示</h4>
      </div>
      <div class="modal-body form-horizontal">
        <div class="box-body">
           	确定要删除所选模板吗？
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default btn-lg pull-left" data-dismiss="modal">取消</button>
        <button type="button" class="btn btn-success btn-lg" ng-click="del_price();">确定</button>
      </div>
    </div>
  </div>
</div>
<!-- 售价模板详情  -->
  <div class="modal fade" id="priceDetails" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" >
  <div class="modal-dialog" role="document" style="width:80%">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" style="text-align:center">模板详情</h4>
      	
      </div>
      <div class="modal-body form-horizontal">
       <div class="box-body">
           <div class="row">
        <div class="col-xs-12">
          
            <div class="box-header">
              
              	<div class="row">
                	<div class="form-group col-md-12">
                        <label class="col-md-2 control-label">适用卡类型</label>
                        <div class="col-md-3 form-group control-label" ng-click="showCardType(priceDetails.name)" style="text-align: left;border: #ded7d7 solid 1px; margin: 0px;height: 34px;">
                         <!--  <input type="text" style="width:80%;" class="col-sm-9 form-control " ng-model="priceDetails.card_type_ids." ng-click="showCardType(priceDetails.name)">-->
                         	<span ng-repeat="t in priceDetails.card_types" ng-show="t.is_checked">{{t.name}}<span>&nbsp;</span></span>
                        </div>
                        <div class="radio radio-info radio-inline col-md-1">
		                        <input type="radio" id="inlineRadio1" value="1" name="mode_type" ng-model="priceDetails.mode_type">
		                        <label for="inlineRadio1"> 按价格 </label>
		                </div>
		                <div class="radio radio-info radio-inline col-md-1">
		                        <input type="radio" id="inlineRadio2" value="2" name="mode_type" ng-model="priceDetails.mode_type">
		                        <label for="inlineRadio2"> 按折扣 </label>
		                </div>
                          <div class="col-md-3 form-group">
                             <input type="number" style="width:80%;text-align:right;" class="col-sm-9 form-control" 
                             	ng-model="priceDetails.discount" ng-disabled="priceDetails.mode_type=='1'" ng-change="baifenbi()">
                          	 <label style="padding-top: 7px;">%</label>
                          </div>
                          <button class="btn pull-right col-md-1 col-md-offset-1" ng-click="download('tb_priceDetail','售价模板详情')"><i class="fa fa-cloud-download"></i>&nbsp;&nbsp;导出</button>
                    </div>
                </div>
             

            </div>
            <!-- /.box-header -->
            <form>
            <div class="box-body table-responsive no-padding" style="max-height: 400px;overflow-y: auto;">
              <table class="table table-hover" id="tb_priceDetail">
                <tbody >
                <tr>
                	<td>序号</td>
                	<td>名称</td>
                	<td>单位</td>
                	<td>默认售价</td>
                	<td>模板价格</td>
                	<td>成本</td>
                	<td>毛利</td>
                	<td>毛利率</td>
                </tr>
                <tr ng-repeat="i in priceDetails.items track by $index">
                	<td>{{$index+1}}</td>
                <!--	<td>{{i.id}}</td>-->
                	<td>{{i.name}}</td>
                	<td>{{i.unit}}</td>
                	<td class="now">{{i.now_price}}</td>
                	<td style="width:15%">
                	<input type="text" class="form-control mode_price" name="mode_price" ng-model="i.mode_price" ng-disabled="priceDetails.mode_type=='2'" ng-change="change(i.mode_price,$index)" autocomplete="off" maxlength="6"> <!--ng-show="priceDetails.mode_type=='0'"-->
                		<!--<input type="text" class="form-control "  ng-model="i.now_price*priceDetails.discount/100" ng-disabled="priceDetails.mode_type=='1'" ng-show="priceDetails.mode_type=='1'">-->
                	</td>
                	<td>{{i.cost_price}}</td>
                	<td class="maoli">{{i.mode_price-i.cost_price}}</td>
                	<!--<td>{{i.maoli}}</td>-->
                	<td class="maolilve">{{(i.mode_price-i.cost_price*2)/(i.mode_price-i.cost_price)| number:2}}</td>
                </tr>
              </tbody>
             </table>
            </div>
            <!-- /.box-body -->
          
          <!-- /.box -->
        </div>
      </div>
          
        </div>
        <!-- /.box-body -->
      
        </div>
      
      <div class="modal-footer">
      	<button type="button" class="btn btn-default btn-lg pull-left" data-dismiss="modal">取消修改</button>
        <button type="submit" class="btn btn-success btn-lg" ng-click="savePriceModule(priceDetails.id);">保存修改</button>
      </div>
    	</form>
    </div>
  </div>
</div>

<!-- 添加模版模态框 -->
<div class="modal fade" id="newPrice" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close" ng-click="cancleNewPrice()"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel" style="text-align:center">新增售价模版</h4>
      </div>
      <div class="modal-body form-horizontal">
        <div class="box-body">
            <div class="form-group">
               <label class="col-sm-3 control-label">模板名称</label>
               <div class="col-sm-9">
                  <input type="text" class="form-control" placeholder="模板名称" ng-model="priceMode.name" maxlength="6">
               </div>
            </div>
            <div class="form-group">
               <label class="col-sm-3 control-label">适用卡类型</label> <!--适用卡类型-->
               <div class="col-sm-9">
                  <span ng-repeat="c in card_types" class="checkbox checkbox-primary col-md-3">
			          <input id="'{{c.id}}'+'c'" class="styled" type="checkbox" name="cardType" ng-model="c.is_checked">
		               <label for="'{{c.id}}'+'c'" id="{{c.name}}">
		                    {{c.name}}
		               </label>
		                 
			      </span>
               </div>
            </div>
            <div class="form-group">
               <label class="col-sm-9 col-md-offset-3 control-label" style="color :red;text-align: left;">一种卡类型只能绑定一个模板！</label>
            </div>
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default btn-lg pull-left" data-dismiss="modal" ng-click="cancleNewPrice()">取消</button>
        <button type="button" class="btn btn-success btn-lg" data-toggle="modal" data-target="#alertCartType">保存</button>
      </div>
    </div>
  </div>
</div>
<!-- 选择卡类型modal -->
<div class="modal fade" id="cardType" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" >
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" style="text-align:center">选择卡类型</h4>
      </div>
      <div class="modal-body form-horizontal">
        <div class="box-body">
        <span ng-repeat="t in priceDetails.card_types">
           	<input type="checkbox" id="'{{t.id}}'+'card'" class="chk_1 level" data-name="{{t.name}}" ng-true-value="true" ng-false-value="false" ng-model="t.is_checked"/>
				<label for="'{{t.id}}'+'card'" class="checklable"></label>{{t.name}}
		</span>
		<div class="form-group">
               <label class="col-sm-9 control-label" style="color :red;text-align: left;">一种卡类型只能绑定一个模板！</label>
            </div>
	    </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default btn-lg pull-left" ng-click='cancleType(priceDetails.id)'>取消</button>
        <button type="button" class="btn btn-success btn-lg" data-dismiss="modal">确定</button>
      </div>
    </div>
  </div>
</div>
<!-- /选择卡类型modal -->
<!--
	作者：leeeeyx@hotmail.com
	时间：2017-07-19
	描述：提示绑定卡类型
-->
<div class="modal fade" id="alertCartType" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" >
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" style="text-align:center">提示</h4>
      </div>
      <div class="modal-body form-horizontal">
        <div class="box-body">
        	<div class="form-group">
        		<label class="col-sm-12 control-label" style="text-align: center;font-size: initial;">若选择的卡类型已绑定其他售价模板,确定保存将会取消与其它模板的绑定！</label>
        		<label class="col-sm-12 control-label" style="text-align: center;font-size: larger;">是否继续执行修改？</label>
        	</div>
      	</div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default btn-lg pull-left" data-dismiss="modal">取消</button>
        <button type="button" class="btn btn-success btn-lg"  ng-click="saveNewPrice()">确定</button>
      </div>
    </div>
  </div>
</div>
